import { GetUserInfo } from "./requestFun/_teseRequest";
import { GetUserInfoFiled } from "./requestFun/_utils";

export class E implements Event {
  bubbles: boolean;
  cancelBubble: boolean;
  cancelable: boolean;
  composed: boolean;
  currentTarget: EventTarget;
  defaultPrevented: boolean;
  eventPhase: number;
  isTrusted: boolean;
  returnValue: boolean;
  srcElement: EventTarget;
  timeStamp: number;
  type: string;
  composedPath(): EventTarget[] {
    throw new Error("Method not implemented.");
  }
  initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void {
    throw new Error("Method not implemented.");
  }
  preventDefault(): void {
    throw new Error("Method not implemented.");
  }
  stopImmediatePropagation(): void {
    throw new Error("Method not implemented.");
  }
  stopPropagation(): void {
    throw new Error("Method not implemented.");
  }
  AT_TARGET: number;
  BUBBLING_PHASE: number;
  CAPTURING_PHASE: number;
  NONE: number;
  target: HTMLElement
}

export const POLICIES = {
  TAPEOUTMONEY_POLICIES: (money: number) => {
    return money > 500000 ? ['部门负责人', '分管副总', '总经理', '董事长'] : ['部门负责人', '分管副总', '总经理']
  },
  TAPEOUTSUMMONEY_POLICIES: (summoney: string) => {
    return summoney === '大于等于50万' ? ['部门负责人', '分管副总', '总经理', '董事长'] : ['部门负责人', '分管副总', '总经理']
  },
  LEAVE_POLICIES: (date: number) => {
    let leave;
    if (date < 1) {
      leave = ['部门负责人', '分管副总']
    }
    else if (date >= 1 && date < 3) {
      leave = ['部门负责人', '分管副总', '总经理']
    }
    else if (date >= 3) {
      leave = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    return leave
  },
  SealApplicantion_POLICIES: () => {
    return ['部门负责人', '分管副总',"正总"]
  },
  EVECT_POLICIES: (date: number) => {
    let evection;
    if (date < 1) {
      evection = ['部门负责人', '分管副总']
    }
    else if (date >= 1 && date < 3) {
      evection = ['部门负责人', '分管副总', '总经理']
    }
    else if (date >= 3) {
      evection = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    return evection
  },
  PURCHAS_POLICIES: (money: number) => {
    let purchas;
    if (money < 2000) {
      purchas = ['部门负责人', '分管副总']
    }
    else if (money >= 2000 && money < 5000) {
      purchas = ['部门负责人', '分管副总', '总经理']
    }
    else if (money >= 5000) {
      purchas = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    return purchas
  },
  PAYMENT_POLICIES: (type: string, money: number) => {
    let payment;
    if (type === '测试费用' && money < 500000) {
      payment = ['部门负责人', '分管副总', '总经理']
    }
    else if (type === '测试费用' && money >= 500000) {
      payment = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    else if (type === '投资费用') {
      payment = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    else if (type === '融资支出') {
      payment = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    else if (type === '日常费用' || type === '汽车费' || type === '差旅费') {
      payment = ['部门负责人', '分管副总']
    }
    if (type === '业务招待费' && money < 2000) {
      payment = ['部门负责人', '分管副总', '总经理']
    }
    if (type === '业务招待费' && money >= 2000) {
      payment = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    if (type === '会务费' && money < 5000) {
      payment = ['部门负责人', '分管副总']
    }
    if (type === '会务费' && money >= 5000 && money < 10000) {
      payment = ['部门负责人', '分管副总', '总经理']
    }
    if (type === '会务费' && money >= 10000) {
      payment = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    if ((type === '广告费' || type === '宣传费') && money < 20000) {
      payment = ['部门负责人', '分管副总']
    }
    if ((type === '广告费' || type === '宣传费') && money >= 20000 && money < 50000) {
      payment = ['部门负责人', '分管副总', '总经理']
    }
    if ((type === '广告费' || type === '宣传费') && money >= 50000) {
      payment = ['部门负责人', '分管副总', '总经理', '董事长']
    }
    return payment
  },

}

export const LOG = 'LOG'

/**
 * 通过用户Id获取用户名称
 * @param id 用户Id
 */
export const GetUserNameById = (id:string) => {
  // return Promise.resolve("HELLO")
  return new Promise(resolve => {
    GetUserInfo(
      {userId: id,
        fileds: null
      }, (res) => {
        resolve({id, name:GetUserInfoFiled(res, 'name')})
      }
    )
  })
}

export const ENTITY = {
  '请假': "ELeave",
  '出差': "EBusinessTrip",
  '采购申请': "EPurchaseRequest",
  '采购确认': "EProcurementConfirmation",
  '用印申请': "EUseSeal",
  '议题申请': "ETopic",
  '会议纪要': "EMeetingMinutes",
  '合同审批': "EContractManagement",
  '薪资审批': "ESalaryInfo",
  '开票功能': "EInvoicing",
  '开收据功能': "EIssueReceipts",
  '报销功能': "EReimbursement",
  '付款功能': "EPayment",
  '资料归档': "EProjectManagement",
  '流片付款': "EChipPayment",
  '设备试验': "EDeviceManagement",
  '订单审批': "EOrder",
  '耗材审批': "EConsumableLog",

} 
